# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  def count_user_group(id)
    user_group = UserGroup.find_all_by_group_id(id)
    if !user_group.blank?
      @user_total = user_group.count
    else
      @user_total = 0
    end
  end

  def find_voter(member,remote)
    @voter = User.find_by_id(member)
    if @voter.blank?
      @voter = remote
    end
  end

  def check_view(params)
    if(params[:controller] == 'home')
      if(params[:action]=='index')
        @view_code = 1
      end
    end
    if(params[:controller] == 'users')
      if(params[:action]=='new')
        @view_code = 2
      end
    end
    if(params[:controller] == 'statements')
      if(params[:action]=='index')
        @view_code = 3
      end
    end
    if(params[:controller] == 'baddays')
      if(params[:action]=='index')
        @view_code = 4
      end
    end
    if(params[:controller] == 'questions')
      if(params[:action]=='index')
        @view_code = 5
      end
    end
    if(params[:controller] == 'contacts')
      if(params[:action]=='index')
        @view_code = 6
      end
    end

    return @view_code
  end

  def check_workspaces_view(params)
    if(params[:controller] == 'workspaces')
      if(params[:action]=='profile')
        @view_code = 1
      end
    end
    if(params[:controller] == 'workspaces')
      if(params[:action]=='statement')
        @view_code = 2
      end
    end
    if(params[:controller] == 'workspaces')
      if(params[:action]=='badday')
        @view_code = 3
      end
    end
    if(params[:controller] == 'workspaces')
      if(params[:action]=='question')
        @view_code = 4
      end
    end
    if(params[:controller] == 'workspaces')
      if(params[:action]=='issue')
        @view_code = 5
      end
    end
    if(params[:controller] == 'workspaces')
      if(params[:action]=='vote')
        @view_code = 6
      end
    end
    if(params[:controller] == 'workspaces')
      if(params[:action]=='station')
        @view_code = 7
      end
    end

    return @view_code
  end
end
